- Write a complete C++ program that asks the user to type a big integer n. It should then ask 4 times for the user to type a smaller value of n and then terminate the program. However, if the user enters a value that is not smaller it should immediately say "Goodbye" and terminate the program.
A sample run of the program:
Type a big integer n: 100
Type a smaller value of n: 20
Type a smaller value of n: 10
Type a smaller value of n: 2
Type a smaller value of n: 1
Another sample run of the program:
Type a big integer n: 100
Type a smaller value of n: 0
Type a smaller value of n: 0
Goodbye
- Write a complete C++ program that does the following:
- Asks the user for an odd positive integer.
- Reads a value n entered by the user. If the value is not legal, force the user to enter a valid input.
- The program prints an n x n grid displaying a backwards Z shape with the following properties:
- A diagonal row of X's running from the top left corner to the bottom right corner.
- With the exception of the X from the diagonal, a row of O's in the top row and bottom row.
A sample run of the program:
Enter value for n: 5
XOOOO
X
X
X
OOOOX
- Write a complete C++ program that does the following:
- It asks the user to enter an odd positive integer.
- The program reads a value n entered by the user. If the value is not legal, the program terminates.
- The program prints an n x n grid displaying a line running from the top left of the screen to the bottom right. The top left half of the line should be made with the character +, the bottom right half should be made with the character x and the very center should be a *.
A sample run of the program:
Enter value for n: 7
+
+
+
*
x
x
x
- Write a complete C++ program that does the following:
- It asks the user to enter an odd positive integer.
- The program reads a value n entered by the user. If the value is not legal, the program terminates.
- The program prints an n x n grid displaying a large letter X. The left half of the X should be made with the character +, the right half should be made with the character x and the very center should be a *.
A sample run of the program:
Enter value for n: 7
+ x
+ x
+ x
*
+ x
+ x
+ x
- Write a complete C++ program that does the following:
- The program asks the user to enter an integer between 1 and 20.
- If the user enters an illegal number, the program repeatedly asks the user to correct their number.
- If the user has not entered a correct number after 10 attemps, the program chooses 10 as the user's number.
- The program prints the cube of the user's number.
A sample run of the program:
Enter an integer between 1 and 20: 100
Out of range. Enter an integer between 1 and 20: -1
Out of range. Enter an integer between 1 and 20: 5
The cube of your number is 125.